package org.example.controller;


import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.example.ai.result.Result;
import org.example.pojo.Works;
import org.example.service.IUsersService;
import org.example.service.IWorksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 作品表，存储用户发布的作品信息及相关属性 前端控制器
 * </p>
 *
 * @author zhx
 * @since 2025-01-17
 */
@Slf4j
@RestController
@RequestMapping("/works")
public class WorksController {
    @Autowired
    private IWorksService worksService;
    @Autowired
    private IUsersService usersService;
    @Operation(summary = "作品详情")
    @GetMapping("/getAllWorks/{workId}")
    public Works getAllWorks(@PathVariable Integer workId)
    {
       return worksService.getAllWorks(workId);
    }


    @Operation(summary = "点赞")
    @GetMapping("/likesContent/{workId}")
    public void likesContent(@PathVariable("workId") Integer workId){
        worksService.likesContent(workId);
    }

    @Operation(summary = "取消点赞")
    @GetMapping("/unlikesContent/{workId}")
    public void unlikesContent(@PathVariable("workId") Integer workId){
        worksService.unlikesContent(workId);
    }

    @Operation(summary = "点赞")
    @GetMapping("/sharesContent/{workId}")
    public void sharesContent(@PathVariable("workId") Integer workId){
        worksService.sharesContent(workId);
    }

    @Operation(summary = "取消点赞")
    @GetMapping("/unsharesContent/{workId}")
    public void unsharesContent(@PathVariable("workId") Integer workId){
        worksService.unsharesContent(workId);
    }
}
